package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServicePayroad;
import com.ruoyi.service.service.IServicePayroadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车程费信息表Controller
 * 
 * @author ZDL
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/service/payroad")
public class ServicePayroadController extends BaseController
{
    @Autowired
    private IServicePayroadService servicePayroadService;

    /**
     * 查询车程费信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServicePayroad servicePayroad)
    {
        startPage();
        List<ServicePayroad> list = servicePayroadService.selectServicePayroadList(servicePayroad);
        return getDataTable(list);
    }

    /**
     * 导出车程费信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:export')")
    @Log(title = "车程费信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicePayroad servicePayroad)
    {
        List<ServicePayroad> list = servicePayroadService.selectServicePayroadList(servicePayroad);
        ExcelUtil<ServicePayroad> util = new ExcelUtil<ServicePayroad>(ServicePayroad.class);
        util.exportExcel(response, list, "车程费信息表数据");
    }

    /**
     * 获取车程费信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:query')")
    @GetMapping(value = "/{payroadId}")
    public AjaxResult getInfo(@PathVariable("payroadId") Long payroadId)
    {
        return success(servicePayroadService.selectServicePayroadByPayroadId(payroadId));
    }

    /**
     * 新增车程费信息表
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:add')")
    @Log(title = "车程费信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicePayroad servicePayroad)
    {
        return toAjax(servicePayroadService.insertServicePayroad(servicePayroad));
    }

    /**
     * 修改车程费信息表
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:edit')")
    @Log(title = "车程费信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicePayroad servicePayroad)
    {
        return toAjax(servicePayroadService.updateServicePayroad(servicePayroad));
    }

    /**
     * 删除车程费信息表
     */
    @PreAuthorize("@ss.hasPermi('service:payroad:remove')")
    @Log(title = "车程费信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payroadIds}")
    public AjaxResult remove(@PathVariable Long[] payroadIds)
    {
        return toAjax(servicePayroadService.deleteServicePayroadByPayroadIds(payroadIds));
    }
}
